package beautiful.butterfly.drds.data_exchange.statistics;


public class SumPerfRecord4Print
{
    public long perfTimeTotal = 0;
    public long averageTime = 0;
    public long maxTime = 0;
    public int maxTaskId = -1;
    public int maxTaskGroupId = -1;
    public int totalCount = 0;

    public long recordsTotal = 0;
    public long sizesTotal = 0;
    public long averageRecords = 0;
    public long averageBytes = 0;
    public long maxRecord = 0;
    public long maxByte = 0;
    public int maxTaskId4Records = -1;
    public int maxTGID4Records = -1;

    public void add(PerfRecord perfRecord)
    {
        if (perfRecord == null)
        {
            return;
        }
        perfTimeTotal += perfRecord.getElapsedTimeInNs();
        if (perfRecord.getElapsedTimeInNs() >= maxTime)
        {
            maxTime = perfRecord.getElapsedTimeInNs();
            maxTaskId = perfRecord.getTaskId();
            maxTaskGroupId = perfRecord.getTaskGroupId();
        }

        recordsTotal += perfRecord.getCount();
        sizesTotal += perfRecord.getSize();
        if (perfRecord.getCount() >= maxRecord)
        {
            maxRecord = perfRecord.getCount();
            maxByte = perfRecord.getSize();
            maxTaskId4Records = perfRecord.getTaskId();
            maxTGID4Records = perfRecord.getTaskGroupId();
        }

        totalCount++;
    }

    public long getPerfTimeTotal()
    {
        return perfTimeTotal;
    }

    public long getAverageTime()
    {
        if (totalCount > 0)
        {
            averageTime = perfTimeTotal / totalCount;
        }
        return averageTime;
    }

    public long getMaxTime()
    {
        return maxTime;
    }

    public int getMaxTaskId()
    {
        return maxTaskId;
    }

    public int getMaxTaskGroupId()
    {
        return maxTaskGroupId;
    }

    public long getRecordsTotal()
    {
        return recordsTotal;
    }

    public long getSizesTotal()
    {
        return sizesTotal;
    }

    public long getAverageRecords()
    {
        if (totalCount > 0)
        {
            averageRecords = recordsTotal / totalCount;
        }
        return averageRecords;
    }

    public long getAverageBytes()
    {
        if (totalCount > 0)
        {
            averageBytes = sizesTotal / totalCount;
        }
        return averageBytes;
    }

    public long getMaxRecord()
    {
        return maxRecord;
    }

    public long getMaxByte()
    {
        return maxByte;
    }

    public int getMaxTaskId4Records()
    {
        return maxTaskId4Records;
    }

    public int getMaxTGID4Records()
    {
        return maxTGID4Records;
    }

    public int getTotalCount()
    {
        return totalCount;
    }
}
